Skip to content

feat: add exactOptional support in type struct#38

Merged
ccharly merged 1 commit into
mainfrom
cc/feat/type-exactOptional-support
Jun 30, 2026
Merged

feat: add exactOptional support in type struct#38
ccharly merged 1 commit into
mainfrom
cc/feat/type-exactOptional-support

Conversation

@ccharly

@ccharly ccharly commented Jun 30, 2026

Copy link
Copy Markdown

Add support of exactOptional with superstruct.type.

We plan to use @metamask/superstruct in @metamask/keyring-api and we already use the combo type + exactOptional (our implementation) there.


Note

Low Risk
Small, localized change to type() entry iteration aligned with existing object() semantics; covered by new tests with no auth or data-path impact.

Overview
Extends type() so exactOptional() fields behave like TypeScript’s optional properties: the key may be missing, but an explicit undefined value is still validated and rejected.

The type() entries generator now skips properties wrapped in exactOptional when the key is not on the object (hasOwnProperty), matching the existing object() behavior.

Adds typing coverage for type + exactOptional, plus validation fixtures for absent keys, present values, and age: undefined failing validation.

Reviewed by Cursor Bugbot for commit e49b9ff. Bugbot is set up for automated code reviews on this repo. Configure here.

@ccharly ccharly requested a review from a team as a code owner June 30, 2026 12:19
@ccharly ccharly changed the title feat: add exactOptional support in type struct feat: add exactOptional support in type struct Jun 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e49b9ff. Configure here.

Comment thread test/validation/type/invalid-exact-optional-undefined.ts
@ccharly ccharly changed the title feat: add exactOptional support in type struct feat: add exactOptional support in type struct Jun 30, 2026
@ccharly ccharly merged commit 970d102 into main Jun 30, 2026
22 checks passed
@ccharly ccharly deleted the cc/feat/type-exactOptional-support branch June 30, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants